#include <iostream>
using namespace std;


//产品类的父类 
class AbstractSmile{
public:
    virtual void transform() = 0;
    virtual void ability() = 0;
    virtual ~AbstractSmile() {}

};

class SheepSmile : public AbstractSmile{
public:
    void transform() override{
        cout << "变成山羊" << endl;
    }
    void ability() override{
        cout << "山羊能力" << endl;
    }
    ~SheepSmile() override {}

};

class LionSmile : public AbstractSmile{
public:
    void transform() override{
        cout << "变成狮子" << endl;
    }
    void ability() override{
        cout << "狮子能力" << endl;
    }
    ~LionSmile() override {}

};

class BatSmile : public AbstractSmile{
public:
    void transform() override{
        cout << "变成蝙蝠" << endl;
    }
    void ability() override{
        cout << "蝙蝠能力" << endl;
    }
    ~BatSmile() override {}

};

//定义工厂类 - 父类
class AbstracFactory{
public:
    virtual AbstractSmile* createSmile() = 0;
    virtual ~AbstracFactory() {}
};

//生产山羊
class SheepFactory : public AbstracFactory{
public:
    AbstractSmile* createSmile() override{
        return new SheepSmile;
    }
    ~SheepFactory(){
        cout << "山羊被析构了..." << endl;
    }

};

//生产狮子
class LionFactory : public AbstracFactory{
public:
    AbstractSmile* createSmile() override{
        return new LionSmile;
    }
    ~LionFactory(){
        cout << "狮子被析构了..." << endl;
    }

};

//生产蝙蝠
class BatFactory : public AbstracFactory{
public:
    AbstractSmile* createSmile() override{
        return new BatSmile;
    }
    ~BatFactory(){
        cout << "蝙蝠被析构了..." << endl;
    }

};


int main(){
    AbstracFactory* factory = new LionFactory;
    AbstractSmile* obj = factory->createSmile();
    obj->transform();
    obj->ability();
    delete obj;
    delete factory;
    return 0;
}